// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

pub mod dataset_service {
    use crate::Result;

    /// A builder for [DatasetService][crate::client::DatasetService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_bigquery_v2::*;
    /// # use builder::dataset_service::ClientBuilder;
    /// # use client::DatasetService;
    /// let builder : ClientBuilder = DatasetService::builder();
    /// let client = builder
    ///     .with_endpoint("https://bigquery.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::DatasetService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = DatasetService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::DatasetService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::DatasetService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DatasetService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [DatasetService::get_dataset][crate::client::DatasetService::get_dataset] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::dataset_service::GetDataset;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetDataset {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetDataset(RequestBuilder<crate::model::GetDatasetRequest>);

    impl GetDataset {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DatasetService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetDatasetRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Dataset> {
            (*self.0.stub)
                .get_dataset(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::GetDatasetRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::GetDatasetRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [dataset_view][crate::model::GetDatasetRequest::dataset_view].
        pub fn set_dataset_view<T: Into<crate::model::get_dataset_request::DatasetView>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.dataset_view = v.into();
            self
        }

        /// Sets the value of [access_policy_version][crate::model::GetDatasetRequest::access_policy_version].
        pub fn set_access_policy_version<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.access_policy_version = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetDataset {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DatasetService::insert_dataset][crate::client::DatasetService::insert_dataset] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::dataset_service::InsertDataset;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> InsertDataset {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct InsertDataset(RequestBuilder<crate::model::InsertDatasetRequest>);

    impl InsertDataset {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DatasetService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::InsertDatasetRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Dataset> {
            (*self.0.stub)
                .insert_dataset(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::InsertDatasetRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset][crate::model::InsertDatasetRequest::dataset].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Dataset>,
        {
            self.0.request.dataset = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [dataset][crate::model::InsertDatasetRequest::dataset].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_dataset<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Dataset>,
        {
            self.0.request.dataset = v.map(|x| x.into());
            self
        }

        /// Sets the value of [access_policy_version][crate::model::InsertDatasetRequest::access_policy_version].
        pub fn set_access_policy_version<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.access_policy_version = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for InsertDataset {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DatasetService::patch_dataset][crate::client::DatasetService::patch_dataset] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::dataset_service::PatchDataset;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> PatchDataset {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct PatchDataset(RequestBuilder<crate::model::UpdateOrPatchDatasetRequest>);

    impl PatchDataset {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DatasetService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateOrPatchDatasetRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Dataset> {
            (*self.0.stub)
                .patch_dataset(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::UpdateOrPatchDatasetRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::UpdateOrPatchDatasetRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [dataset][crate::model::UpdateOrPatchDatasetRequest::dataset].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Dataset>,
        {
            self.0.request.dataset = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [dataset][crate::model::UpdateOrPatchDatasetRequest::dataset].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_dataset<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Dataset>,
        {
            self.0.request.dataset = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mode][crate::model::UpdateOrPatchDatasetRequest::update_mode].
        pub fn set_update_mode<
            T: Into<crate::model::update_or_patch_dataset_request::UpdateMode>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.update_mode = v.into();
            self
        }

        /// Sets the value of [access_policy_version][crate::model::UpdateOrPatchDatasetRequest::access_policy_version].
        pub fn set_access_policy_version<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.access_policy_version = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for PatchDataset {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DatasetService::update_dataset][crate::client::DatasetService::update_dataset] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::dataset_service::UpdateDataset;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateDataset {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateDataset(RequestBuilder<crate::model::UpdateOrPatchDatasetRequest>);

    impl UpdateDataset {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DatasetService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateOrPatchDatasetRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Dataset> {
            (*self.0.stub)
                .update_dataset(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::UpdateOrPatchDatasetRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::UpdateOrPatchDatasetRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [dataset][crate::model::UpdateOrPatchDatasetRequest::dataset].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Dataset>,
        {
            self.0.request.dataset = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [dataset][crate::model::UpdateOrPatchDatasetRequest::dataset].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_dataset<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Dataset>,
        {
            self.0.request.dataset = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mode][crate::model::UpdateOrPatchDatasetRequest::update_mode].
        pub fn set_update_mode<
            T: Into<crate::model::update_or_patch_dataset_request::UpdateMode>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.update_mode = v.into();
            self
        }

        /// Sets the value of [access_policy_version][crate::model::UpdateOrPatchDatasetRequest::access_policy_version].
        pub fn set_access_policy_version<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.access_policy_version = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateDataset {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DatasetService::delete_dataset][crate::client::DatasetService::delete_dataset] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::dataset_service::DeleteDataset;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteDataset {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteDataset(RequestBuilder<crate::model::DeleteDatasetRequest>);

    impl DeleteDataset {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DatasetService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteDatasetRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_dataset(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::DeleteDatasetRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::DeleteDatasetRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [delete_contents][crate::model::DeleteDatasetRequest::delete_contents].
        pub fn set_delete_contents<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.delete_contents = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteDataset {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DatasetService::list_datasets][crate::client::DatasetService::list_datasets] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::dataset_service::ListDatasets;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListDatasets {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListDatasets(RequestBuilder<crate::model::ListDatasetsRequest>);

    impl ListDatasets {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DatasetService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListDatasetsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::DatasetList> {
            (*self.0.stub)
                .list_datasets(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::DatasetList, gax::error::Error> {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::DatasetList, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [project_id][crate::model::ListDatasetsRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [max_results][crate::model::ListDatasetsRequest::max_results].
        pub fn set_max_results<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::UInt32Value>,
        {
            self.0.request.max_results = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [max_results][crate::model::ListDatasetsRequest::max_results].
        pub fn set_or_clear_max_results<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::UInt32Value>,
        {
            self.0.request.max_results = v.map(|x| x.into());
            self
        }

        /// Sets the value of [page_token][crate::model::ListDatasetsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [all][crate::model::ListDatasetsRequest::all].
        pub fn set_all<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.all = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::ListDatasetsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListDatasets {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DatasetService::undelete_dataset][crate::client::DatasetService::undelete_dataset] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::dataset_service::UndeleteDataset;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UndeleteDataset {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UndeleteDataset(RequestBuilder<crate::model::UndeleteDatasetRequest>);

    impl UndeleteDataset {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DatasetService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UndeleteDatasetRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Dataset> {
            (*self.0.stub)
                .undelete_dataset(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::UndeleteDatasetRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::UndeleteDatasetRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [deletion_time][crate::model::UndeleteDatasetRequest::deletion_time].
        pub fn set_deletion_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.deletion_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [deletion_time][crate::model::UndeleteDatasetRequest::deletion_time].
        pub fn set_or_clear_deletion_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.deletion_time = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UndeleteDataset {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod job_service {
    use crate::Result;

    /// A builder for [JobService][crate::client::JobService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_bigquery_v2::*;
    /// # use builder::job_service::ClientBuilder;
    /// # use client::JobService;
    /// let builder : ClientBuilder = JobService::builder();
    /// let client = builder
    ///     .with_endpoint("https://bigquery.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::JobService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = JobService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::JobService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::JobService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::JobService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [JobService::cancel_job][crate::client::JobService::cancel_job] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::job_service::CancelJob;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelJob {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelJob(RequestBuilder<crate::model::CancelJobRequest>);

    impl CancelJob {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::JobService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CancelJobRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::JobCancelResponse> {
            (*self.0.stub)
                .cancel_job(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::CancelJobRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [job_id][crate::model::CancelJobRequest::job_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_job_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.job_id = v.into();
            self
        }

        /// Sets the value of [location][crate::model::CancelJobRequest::location].
        pub fn set_location<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.location = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelJob {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [JobService::get_job][crate::client::JobService::get_job] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::job_service::GetJob;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetJob {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetJob(RequestBuilder<crate::model::GetJobRequest>);

    impl GetJob {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::JobService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetJobRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Job> {
            (*self.0.stub)
                .get_job(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::GetJobRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [job_id][crate::model::GetJobRequest::job_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_job_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.job_id = v.into();
            self
        }

        /// Sets the value of [location][crate::model::GetJobRequest::location].
        pub fn set_location<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.location = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetJob {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [JobService::insert_job][crate::client::JobService::insert_job] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::job_service::InsertJob;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> InsertJob {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct InsertJob(RequestBuilder<crate::model::InsertJobRequest>);

    impl InsertJob {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::JobService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::InsertJobRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Job> {
            (*self.0.stub)
                .insert_job(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::InsertJobRequest::project_id].
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [job][crate::model::InsertJobRequest::job].
        pub fn set_job<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Job>,
        {
            self.0.request.job = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [job][crate::model::InsertJobRequest::job].
        pub fn set_or_clear_job<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Job>,
        {
            self.0.request.job = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for InsertJob {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [JobService::delete_job][crate::client::JobService::delete_job] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::job_service::DeleteJob;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteJob {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteJob(RequestBuilder<crate::model::DeleteJobRequest>);

    impl DeleteJob {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::JobService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteJobRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_job(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::DeleteJobRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [job_id][crate::model::DeleteJobRequest::job_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_job_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.job_id = v.into();
            self
        }

        /// Sets the value of [location][crate::model::DeleteJobRequest::location].
        pub fn set_location<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.location = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteJob {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [JobService::list_jobs][crate::client::JobService::list_jobs] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::job_service::ListJobs;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListJobs {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListJobs(RequestBuilder<crate::model::ListJobsRequest>);

    impl ListJobs {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::JobService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListJobsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::JobList> {
            (*self.0.stub)
                .list_jobs(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::JobList, gax::error::Error> {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::JobList, gax::error::Error> {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [project_id][crate::model::ListJobsRequest::project_id].
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [all_users][crate::model::ListJobsRequest::all_users].
        pub fn set_all_users<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.all_users = v.into();
            self
        }

        /// Sets the value of [max_results][crate::model::ListJobsRequest::max_results].
        pub fn set_max_results<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Int32Value>,
        {
            self.0.request.max_results = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [max_results][crate::model::ListJobsRequest::max_results].
        pub fn set_or_clear_max_results<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Int32Value>,
        {
            self.0.request.max_results = v.map(|x| x.into());
            self
        }

        /// Sets the value of [min_creation_time][crate::model::ListJobsRequest::min_creation_time].
        pub fn set_min_creation_time<T: Into<u64>>(mut self, v: T) -> Self {
            self.0.request.min_creation_time = v.into();
            self
        }

        /// Sets the value of [max_creation_time][crate::model::ListJobsRequest::max_creation_time].
        pub fn set_max_creation_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::UInt64Value>,
        {
            self.0.request.max_creation_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [max_creation_time][crate::model::ListJobsRequest::max_creation_time].
        pub fn set_or_clear_max_creation_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::UInt64Value>,
        {
            self.0.request.max_creation_time = v.map(|x| x.into());
            self
        }

        /// Sets the value of [page_token][crate::model::ListJobsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [projection][crate::model::ListJobsRequest::projection].
        pub fn set_projection<T: Into<crate::model::list_jobs_request::Projection>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.projection = v.into();
            self
        }

        /// Sets the value of [state_filter][crate::model::ListJobsRequest::state_filter].
        pub fn set_state_filter<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::list_jobs_request::StateFilter>,
        {
            use std::iter::Iterator;
            self.0.request.state_filter = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [parent_job_id][crate::model::ListJobsRequest::parent_job_id].
        pub fn set_parent_job_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent_job_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListJobs {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [JobService::get_query_results][crate::client::JobService::get_query_results] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::job_service::GetQueryResults;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetQueryResults {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetQueryResults(RequestBuilder<crate::model::GetQueryResultsRequest>);

    impl GetQueryResults {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::JobService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetQueryResultsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::GetQueryResultsResponse> {
            (*self.0.stub)
                .get_query_results(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::GetQueryResultsRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [job_id][crate::model::GetQueryResultsRequest::job_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_job_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.job_id = v.into();
            self
        }

        /// Sets the value of [start_index][crate::model::GetQueryResultsRequest::start_index].
        pub fn set_start_index<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::UInt64Value>,
        {
            self.0.request.start_index = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [start_index][crate::model::GetQueryResultsRequest::start_index].
        pub fn set_or_clear_start_index<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::UInt64Value>,
        {
            self.0.request.start_index = v.map(|x| x.into());
            self
        }

        /// Sets the value of [page_token][crate::model::GetQueryResultsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [max_results][crate::model::GetQueryResultsRequest::max_results].
        pub fn set_max_results<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::UInt32Value>,
        {
            self.0.request.max_results = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [max_results][crate::model::GetQueryResultsRequest::max_results].
        pub fn set_or_clear_max_results<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::UInt32Value>,
        {
            self.0.request.max_results = v.map(|x| x.into());
            self
        }

        /// Sets the value of [timeout_ms][crate::model::GetQueryResultsRequest::timeout_ms].
        pub fn set_timeout_ms<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::UInt32Value>,
        {
            self.0.request.timeout_ms = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [timeout_ms][crate::model::GetQueryResultsRequest::timeout_ms].
        pub fn set_or_clear_timeout_ms<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::UInt32Value>,
        {
            self.0.request.timeout_ms = v.map(|x| x.into());
            self
        }

        /// Sets the value of [location][crate::model::GetQueryResultsRequest::location].
        pub fn set_location<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.location = v.into();
            self
        }

        /// Sets the value of [format_options][crate::model::GetQueryResultsRequest::format_options].
        pub fn set_format_options<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::DataFormatOptions>,
        {
            self.0.request.format_options = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [format_options][crate::model::GetQueryResultsRequest::format_options].
        pub fn set_or_clear_format_options<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::DataFormatOptions>,
        {
            self.0.request.format_options = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetQueryResults {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [JobService::query][crate::client::JobService::query] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::job_service::Query;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> Query {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct Query(RequestBuilder<crate::model::PostQueryRequest>);

    impl Query {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::JobService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::PostQueryRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::QueryResponse> {
            (*self.0.stub)
                .query(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::PostQueryRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [query_request][crate::model::PostQueryRequest::query_request].
        pub fn set_query_request<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::QueryRequest>,
        {
            self.0.request.query_request = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [query_request][crate::model::PostQueryRequest::query_request].
        pub fn set_or_clear_query_request<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::QueryRequest>,
        {
            self.0.request.query_request = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for Query {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod model_service {
    use crate::Result;

    /// A builder for [ModelService][crate::client::ModelService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_bigquery_v2::*;
    /// # use builder::model_service::ClientBuilder;
    /// # use client::ModelService;
    /// let builder : ClientBuilder = ModelService::builder();
    /// let client = builder
    ///     .with_endpoint("https://bigquery.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::ModelService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = ModelService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::ModelService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [ModelService::get_model][crate::client::ModelService::get_model] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::model_service::GetModel;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetModel {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetModel(RequestBuilder<crate::model::GetModelRequest>);

    impl GetModel {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetModelRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Model> {
            (*self.0.stub)
                .get_model(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::GetModelRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::GetModelRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [model_id][crate::model::GetModelRequest::model_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_model_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.model_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetModel {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ModelService::list_models][crate::client::ModelService::list_models] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::model_service::ListModels;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListModels {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListModels(RequestBuilder<crate::model::ListModelsRequest>);

    impl ListModels {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListModelsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListModelsResponse> {
            (*self.0.stub)
                .list_models(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListModelsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListModelsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [project_id][crate::model::ListModelsRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::ListModelsRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [max_results][crate::model::ListModelsRequest::max_results].
        pub fn set_max_results<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::UInt32Value>,
        {
            self.0.request.max_results = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [max_results][crate::model::ListModelsRequest::max_results].
        pub fn set_or_clear_max_results<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::UInt32Value>,
        {
            self.0.request.max_results = v.map(|x| x.into());
            self
        }

        /// Sets the value of [page_token][crate::model::ListModelsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListModels {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ModelService::patch_model][crate::client::ModelService::patch_model] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::model_service::PatchModel;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> PatchModel {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct PatchModel(RequestBuilder<crate::model::PatchModelRequest>);

    impl PatchModel {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::PatchModelRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Model> {
            (*self.0.stub)
                .patch_model(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::PatchModelRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::PatchModelRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [model_id][crate::model::PatchModelRequest::model_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_model_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.model_id = v.into();
            self
        }

        /// Sets the value of [model][crate::model::PatchModelRequest::model].
        ///
        /// This is a **required** field for requests.
        pub fn set_model<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Model>,
        {
            self.0.request.model = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [model][crate::model::PatchModelRequest::model].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Model>,
        {
            self.0.request.model = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for PatchModel {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ModelService::delete_model][crate::client::ModelService::delete_model] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::model_service::DeleteModel;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteModel {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteModel(RequestBuilder<crate::model::DeleteModelRequest>);

    impl DeleteModel {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteModelRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_model(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::DeleteModelRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::DeleteModelRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [model_id][crate::model::DeleteModelRequest::model_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_model_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.model_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteModel {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod project_service {
    use crate::Result;

    /// A builder for [ProjectService][crate::client::ProjectService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_bigquery_v2::*;
    /// # use builder::project_service::ClientBuilder;
    /// # use client::ProjectService;
    /// let builder : ClientBuilder = ProjectService::builder();
    /// let client = builder
    ///     .with_endpoint("https://bigquery.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::ProjectService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = ProjectService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::ProjectService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::ProjectService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProjectService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [ProjectService::get_service_account][crate::client::ProjectService::get_service_account] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::project_service::GetServiceAccount;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetServiceAccount {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetServiceAccount(RequestBuilder<crate::model::GetServiceAccountRequest>);

    impl GetServiceAccount {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProjectService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetServiceAccountRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::GetServiceAccountResponse> {
            (*self.0.stub)
                .get_service_account(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::GetServiceAccountRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetServiceAccount {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod routine_service {
    use crate::Result;

    /// A builder for [RoutineService][crate::client::RoutineService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_bigquery_v2::*;
    /// # use builder::routine_service::ClientBuilder;
    /// # use client::RoutineService;
    /// let builder : ClientBuilder = RoutineService::builder();
    /// let client = builder
    ///     .with_endpoint("https://bigquery.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::RoutineService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = RoutineService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::RoutineService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::RoutineService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RoutineService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [RoutineService::get_routine][crate::client::RoutineService::get_routine] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::routine_service::GetRoutine;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetRoutine {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetRoutine(RequestBuilder<crate::model::GetRoutineRequest>);

    impl GetRoutine {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RoutineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetRoutineRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Routine> {
            (*self.0.stub)
                .get_routine(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::GetRoutineRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::GetRoutineRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [routine_id][crate::model::GetRoutineRequest::routine_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_routine_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.routine_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetRoutine {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RoutineService::insert_routine][crate::client::RoutineService::insert_routine] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::routine_service::InsertRoutine;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> InsertRoutine {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct InsertRoutine(RequestBuilder<crate::model::InsertRoutineRequest>);

    impl InsertRoutine {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RoutineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::InsertRoutineRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Routine> {
            (*self.0.stub)
                .insert_routine(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::InsertRoutineRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::InsertRoutineRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [routine][crate::model::InsertRoutineRequest::routine].
        ///
        /// This is a **required** field for requests.
        pub fn set_routine<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Routine>,
        {
            self.0.request.routine = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [routine][crate::model::InsertRoutineRequest::routine].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_routine<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Routine>,
        {
            self.0.request.routine = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for InsertRoutine {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RoutineService::update_routine][crate::client::RoutineService::update_routine] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::routine_service::UpdateRoutine;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateRoutine {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateRoutine(RequestBuilder<crate::model::UpdateRoutineRequest>);

    impl UpdateRoutine {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RoutineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateRoutineRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Routine> {
            (*self.0.stub)
                .update_routine(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::UpdateRoutineRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::UpdateRoutineRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [routine_id][crate::model::UpdateRoutineRequest::routine_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_routine_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.routine_id = v.into();
            self
        }

        /// Sets the value of [routine][crate::model::UpdateRoutineRequest::routine].
        ///
        /// This is a **required** field for requests.
        pub fn set_routine<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Routine>,
        {
            self.0.request.routine = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [routine][crate::model::UpdateRoutineRequest::routine].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_routine<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Routine>,
        {
            self.0.request.routine = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateRoutine {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RoutineService::delete_routine][crate::client::RoutineService::delete_routine] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::routine_service::DeleteRoutine;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteRoutine {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteRoutine(RequestBuilder<crate::model::DeleteRoutineRequest>);

    impl DeleteRoutine {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RoutineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteRoutineRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_routine(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::DeleteRoutineRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::DeleteRoutineRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [routine_id][crate::model::DeleteRoutineRequest::routine_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_routine_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.routine_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteRoutine {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RoutineService::list_routines][crate::client::RoutineService::list_routines] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::routine_service::ListRoutines;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListRoutines {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListRoutines(RequestBuilder<crate::model::ListRoutinesRequest>);

    impl ListRoutines {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RoutineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListRoutinesRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListRoutinesResponse> {
            (*self.0.stub)
                .list_routines(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListRoutinesResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListRoutinesResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [project_id][crate::model::ListRoutinesRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::ListRoutinesRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [max_results][crate::model::ListRoutinesRequest::max_results].
        pub fn set_max_results<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::UInt32Value>,
        {
            self.0.request.max_results = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [max_results][crate::model::ListRoutinesRequest::max_results].
        pub fn set_or_clear_max_results<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::UInt32Value>,
        {
            self.0.request.max_results = v.map(|x| x.into());
            self
        }

        /// Sets the value of [page_token][crate::model::ListRoutinesRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::ListRoutinesRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListRoutines {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod row_access_policy_service {
    use crate::Result;

    /// A builder for [RowAccessPolicyService][crate::client::RowAccessPolicyService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_bigquery_v2::*;
    /// # use builder::row_access_policy_service::ClientBuilder;
    /// # use client::RowAccessPolicyService;
    /// let builder : ClientBuilder = RowAccessPolicyService::builder();
    /// let client = builder
    ///     .with_endpoint("https://bigquery.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::RowAccessPolicyService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = RowAccessPolicyService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::RowAccessPolicyService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::RowAccessPolicyService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RowAccessPolicyService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [RowAccessPolicyService::list_row_access_policies][crate::client::RowAccessPolicyService::list_row_access_policies] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::row_access_policy_service::ListRowAccessPolicies;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListRowAccessPolicies {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListRowAccessPolicies(RequestBuilder<crate::model::ListRowAccessPoliciesRequest>);

    impl ListRowAccessPolicies {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RowAccessPolicyService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListRowAccessPoliciesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListRowAccessPoliciesResponse> {
            (*self.0.stub)
                .list_row_access_policies(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListRowAccessPoliciesResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            crate::model::ListRowAccessPoliciesResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [project_id][crate::model::ListRowAccessPoliciesRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::ListRowAccessPoliciesRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [table_id][crate::model::ListRowAccessPoliciesRequest::table_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_table_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.table_id = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListRowAccessPoliciesRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListRowAccessPoliciesRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListRowAccessPolicies {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RowAccessPolicyService::get_row_access_policy][crate::client::RowAccessPolicyService::get_row_access_policy] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::row_access_policy_service::GetRowAccessPolicy;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetRowAccessPolicy {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetRowAccessPolicy(RequestBuilder<crate::model::GetRowAccessPolicyRequest>);

    impl GetRowAccessPolicy {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RowAccessPolicyService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetRowAccessPolicyRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::RowAccessPolicy> {
            (*self.0.stub)
                .get_row_access_policy(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::GetRowAccessPolicyRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::GetRowAccessPolicyRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [table_id][crate::model::GetRowAccessPolicyRequest::table_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_table_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.table_id = v.into();
            self
        }

        /// Sets the value of [policy_id][crate::model::GetRowAccessPolicyRequest::policy_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_policy_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.policy_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetRowAccessPolicy {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RowAccessPolicyService::create_row_access_policy][crate::client::RowAccessPolicyService::create_row_access_policy] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::row_access_policy_service::CreateRowAccessPolicy;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateRowAccessPolicy {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateRowAccessPolicy(RequestBuilder<crate::model::CreateRowAccessPolicyRequest>);

    impl CreateRowAccessPolicy {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RowAccessPolicyService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateRowAccessPolicyRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::RowAccessPolicy> {
            (*self.0.stub)
                .create_row_access_policy(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::CreateRowAccessPolicyRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::CreateRowAccessPolicyRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [table_id][crate::model::CreateRowAccessPolicyRequest::table_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_table_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.table_id = v.into();
            self
        }

        /// Sets the value of [row_access_policy][crate::model::CreateRowAccessPolicyRequest::row_access_policy].
        ///
        /// This is a **required** field for requests.
        pub fn set_row_access_policy<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::RowAccessPolicy>,
        {
            self.0.request.row_access_policy = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [row_access_policy][crate::model::CreateRowAccessPolicyRequest::row_access_policy].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_row_access_policy<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::RowAccessPolicy>,
        {
            self.0.request.row_access_policy = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateRowAccessPolicy {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RowAccessPolicyService::update_row_access_policy][crate::client::RowAccessPolicyService::update_row_access_policy] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::row_access_policy_service::UpdateRowAccessPolicy;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateRowAccessPolicy {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateRowAccessPolicy(RequestBuilder<crate::model::UpdateRowAccessPolicyRequest>);

    impl UpdateRowAccessPolicy {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RowAccessPolicyService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateRowAccessPolicyRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::RowAccessPolicy> {
            (*self.0.stub)
                .update_row_access_policy(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::UpdateRowAccessPolicyRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::UpdateRowAccessPolicyRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [table_id][crate::model::UpdateRowAccessPolicyRequest::table_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_table_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.table_id = v.into();
            self
        }

        /// Sets the value of [policy_id][crate::model::UpdateRowAccessPolicyRequest::policy_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_policy_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.policy_id = v.into();
            self
        }

        /// Sets the value of [row_access_policy][crate::model::UpdateRowAccessPolicyRequest::row_access_policy].
        ///
        /// This is a **required** field for requests.
        pub fn set_row_access_policy<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::RowAccessPolicy>,
        {
            self.0.request.row_access_policy = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [row_access_policy][crate::model::UpdateRowAccessPolicyRequest::row_access_policy].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_row_access_policy<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::RowAccessPolicy>,
        {
            self.0.request.row_access_policy = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateRowAccessPolicy {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RowAccessPolicyService::delete_row_access_policy][crate::client::RowAccessPolicyService::delete_row_access_policy] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::row_access_policy_service::DeleteRowAccessPolicy;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteRowAccessPolicy {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteRowAccessPolicy(RequestBuilder<crate::model::DeleteRowAccessPolicyRequest>);

    impl DeleteRowAccessPolicy {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RowAccessPolicyService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteRowAccessPolicyRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_row_access_policy(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::DeleteRowAccessPolicyRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::DeleteRowAccessPolicyRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [table_id][crate::model::DeleteRowAccessPolicyRequest::table_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_table_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.table_id = v.into();
            self
        }

        /// Sets the value of [policy_id][crate::model::DeleteRowAccessPolicyRequest::policy_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_policy_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.policy_id = v.into();
            self
        }

        /// Sets the value of [force][crate::model::DeleteRowAccessPolicyRequest::force].
        pub fn set_force<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<bool>,
        {
            self.0.request.force = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [force][crate::model::DeleteRowAccessPolicyRequest::force].
        pub fn set_or_clear_force<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<bool>,
        {
            self.0.request.force = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteRowAccessPolicy {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RowAccessPolicyService::batch_delete_row_access_policies][crate::client::RowAccessPolicyService::batch_delete_row_access_policies] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::row_access_policy_service::BatchDeleteRowAccessPolicies;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> BatchDeleteRowAccessPolicies {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct BatchDeleteRowAccessPolicies(
        RequestBuilder<crate::model::BatchDeleteRowAccessPoliciesRequest>,
    );

    impl BatchDeleteRowAccessPolicies {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RowAccessPolicyService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::BatchDeleteRowAccessPoliciesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .batch_delete_row_access_policies(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::BatchDeleteRowAccessPoliciesRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::BatchDeleteRowAccessPoliciesRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [table_id][crate::model::BatchDeleteRowAccessPoliciesRequest::table_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_table_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.table_id = v.into();
            self
        }

        /// Sets the value of [policy_ids][crate::model::BatchDeleteRowAccessPoliciesRequest::policy_ids].
        ///
        /// This is a **required** field for requests.
        pub fn set_policy_ids<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.0.request.policy_ids = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [force][crate::model::BatchDeleteRowAccessPoliciesRequest::force].
        pub fn set_force<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<bool>,
        {
            self.0.request.force = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [force][crate::model::BatchDeleteRowAccessPoliciesRequest::force].
        pub fn set_or_clear_force<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<bool>,
        {
            self.0.request.force = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for BatchDeleteRowAccessPolicies {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod table_service {
    use crate::Result;

    /// A builder for [TableService][crate::client::TableService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_bigquery_v2::*;
    /// # use builder::table_service::ClientBuilder;
    /// # use client::TableService;
    /// let builder : ClientBuilder = TableService::builder();
    /// let client = builder
    ///     .with_endpoint("https://bigquery.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::TableService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = TableService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::TableService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::TableService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TableService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [TableService::get_table][crate::client::TableService::get_table] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::table_service::GetTable;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetTable {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetTable(RequestBuilder<crate::model::GetTableRequest>);

    impl GetTable {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TableService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetTableRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Table> {
            (*self.0.stub)
                .get_table(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::GetTableRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::GetTableRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [table_id][crate::model::GetTableRequest::table_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_table_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.table_id = v.into();
            self
        }

        /// Sets the value of [selected_fields][crate::model::GetTableRequest::selected_fields].
        pub fn set_selected_fields<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.selected_fields = v.into();
            self
        }

        /// Sets the value of [view][crate::model::GetTableRequest::view].
        pub fn set_view<T: Into<crate::model::get_table_request::TableMetadataView>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.view = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetTable {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TableService::insert_table][crate::client::TableService::insert_table] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::table_service::InsertTable;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> InsertTable {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct InsertTable(RequestBuilder<crate::model::InsertTableRequest>);

    impl InsertTable {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TableService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::InsertTableRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Table> {
            (*self.0.stub)
                .insert_table(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::InsertTableRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::InsertTableRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [table][crate::model::InsertTableRequest::table].
        ///
        /// This is a **required** field for requests.
        pub fn set_table<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Table>,
        {
            self.0.request.table = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [table][crate::model::InsertTableRequest::table].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_table<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Table>,
        {
            self.0.request.table = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for InsertTable {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TableService::patch_table][crate::client::TableService::patch_table] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::table_service::PatchTable;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> PatchTable {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct PatchTable(RequestBuilder<crate::model::UpdateOrPatchTableRequest>);

    impl PatchTable {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TableService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateOrPatchTableRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Table> {
            (*self.0.stub)
                .patch_table(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::UpdateOrPatchTableRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::UpdateOrPatchTableRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [table_id][crate::model::UpdateOrPatchTableRequest::table_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_table_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.table_id = v.into();
            self
        }

        /// Sets the value of [table][crate::model::UpdateOrPatchTableRequest::table].
        ///
        /// This is a **required** field for requests.
        pub fn set_table<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Table>,
        {
            self.0.request.table = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [table][crate::model::UpdateOrPatchTableRequest::table].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_table<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Table>,
        {
            self.0.request.table = v.map(|x| x.into());
            self
        }

        /// Sets the value of [autodetect_schema][crate::model::UpdateOrPatchTableRequest::autodetect_schema].
        pub fn set_autodetect_schema<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.autodetect_schema = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for PatchTable {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TableService::update_table][crate::client::TableService::update_table] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::table_service::UpdateTable;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateTable {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateTable(RequestBuilder<crate::model::UpdateOrPatchTableRequest>);

    impl UpdateTable {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TableService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateOrPatchTableRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Table> {
            (*self.0.stub)
                .update_table(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::UpdateOrPatchTableRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::UpdateOrPatchTableRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [table_id][crate::model::UpdateOrPatchTableRequest::table_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_table_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.table_id = v.into();
            self
        }

        /// Sets the value of [table][crate::model::UpdateOrPatchTableRequest::table].
        ///
        /// This is a **required** field for requests.
        pub fn set_table<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Table>,
        {
            self.0.request.table = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [table][crate::model::UpdateOrPatchTableRequest::table].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_table<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Table>,
        {
            self.0.request.table = v.map(|x| x.into());
            self
        }

        /// Sets the value of [autodetect_schema][crate::model::UpdateOrPatchTableRequest::autodetect_schema].
        pub fn set_autodetect_schema<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.autodetect_schema = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateTable {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TableService::delete_table][crate::client::TableService::delete_table] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::table_service::DeleteTable;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteTable {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteTable(RequestBuilder<crate::model::DeleteTableRequest>);

    impl DeleteTable {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TableService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteTableRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_table(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [project_id][crate::model::DeleteTableRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::DeleteTableRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [table_id][crate::model::DeleteTableRequest::table_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_table_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.table_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteTable {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TableService::list_tables][crate::client::TableService::list_tables] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_bigquery_v2::builder;
    /// use builder::table_service::ListTables;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListTables {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListTables(RequestBuilder<crate::model::ListTablesRequest>);

    impl ListTables {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TableService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListTablesRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::TableList> {
            (*self.0.stub)
                .list_tables(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::TableList, gax::error::Error> {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::TableList, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [project_id][crate::model::ListTablesRequest::project_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project_id = v.into();
            self
        }

        /// Sets the value of [dataset_id][crate::model::ListTablesRequest::dataset_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset_id = v.into();
            self
        }

        /// Sets the value of [max_results][crate::model::ListTablesRequest::max_results].
        pub fn set_max_results<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::UInt32Value>,
        {
            self.0.request.max_results = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [max_results][crate::model::ListTablesRequest::max_results].
        pub fn set_or_clear_max_results<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::UInt32Value>,
        {
            self.0.request.max_results = v.map(|x| x.into());
            self
        }

        /// Sets the value of [page_token][crate::model::ListTablesRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListTables {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}
